package com.wyq.jpa.controller;

import com.wyq.jpa.dao.LinkDao;
import com.wyq.jpa.model.Blog;
import com.wyq.jpa.model.Link;
import com.wyq.jpa.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;


import com.wyq.jpa.service.UserService;
import org.springframework.stereotype.Service;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("admin")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
public class AdminController {

	@Autowired
	private UserService userService;

	@Autowired
	private LinkDao linkDao;

	@Autowired
	private LinkService linkService;

	@GET
	@Path("/info")
	public String login(@QueryParam("username") String username, @QueryParam("password") String password){
		if(userService.check(username, password)){
			return "admin/main";
		}
		return "admin/login";
	}

	@GET
	@Path("/info2")
	public String login1(){
		return "admin/login";
	}

	@GET
	@Path("/info1")
	public String main(){
		linkService.update();
		return "admin/index";
	}
}
